//
//  TTMainEventHandle.m
//  TaoTuo
//
//  Created by 周晨晔 on 2019/9/21.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTMainEventHandle.h"
#import "TTCollectionViewController.h"
#import "TTMarketViewController.h"
#import "TTAddressManagerViewController.h"
#import "TTCouponViewController.h"
#import "TTNotifyViewController.h"
#import "TTMessageViewController.h"
#import "TTCalculatorViewController.h"
#import "TTFactoryAddressViewController.h"

@implementation TTMainEventHandle
{
    UIViewController *VC;
}

+ (void)handleSelectorWithString:(NSString *)string viewController:(UIViewController *)vc
{
    TTMainEventHandle *main = [[self alloc] init];
    main->VC = vc;
    //图片名_action 作为实现方法
    SEL sel = NSSelectorFromString([NSString stringWithFormat:@"%@_action", string]);
    if ([main respondsToSelector:sel]) {
        IMP imp = [main methodForSelector:sel];
        void (*func)(id, SEL) = (void *)imp;
        func(main, sel);
    } else {
        [[UIApplication sharedApplication].keyWindow makeToast:@"暂未实现"];
    }
    
}


// 优惠券
- (void)youhuiquan_action
{
    TTCouponViewController *couponVC = [[TTCouponViewController alloc] initWithCouponState:0];
    [self->VC.navigationController pushViewController:couponVC animated:YES];
}

- (void)shoucang_action
{
    TTCollectionViewController *collectionVC = [[TTCollectionViewController alloc] initWithPageType:PageTypeWithCollection];
    [self->VC.navigationController pushViewController:collectionVC animated:YES];
}

- (void)zuji_action
{
    TTCollectionViewController *collectionVC = [[TTCollectionViewController alloc] initWithPageType:PageTypeWithTrack];
    [self->VC.navigationController pushViewController:collectionVC animated:YES];
}

- (void)dizhi_action
{
    TTAddressManagerViewController *addressVC = [[TTAddressManagerViewController alloc] init];
    [self->VC.navigationController pushViewController:addressVC animated:YES];
}

- (void)hangqing_action
{
    TTMarketViewController *marketVC = [[TTMarketViewController alloc] init];
    [self->VC.navigationController pushViewController:marketVC animated:YES];
}

// 公告
- (void)notification_action
{
    TTNotifyViewController *notifyVC = [[TTNotifyViewController alloc] initWithPageType:NotifyPageTypeWithNotify];
    [self->VC.navigationController pushViewController:notifyVC animated:YES];
    
}

// 帮助
- (void)bangzhu_action
{
    TTNotifyViewController *notifyVC = [[TTNotifyViewController alloc] initWithPageType:NotifyPageTypeWithHelp];
    [self->VC.navigationController pushViewController:notifyVC animated:YES];
}

- (void)zhengshu_action
{
    TTMessageViewController *messageVC = [[TTMessageViewController alloc] init];
    messageVC.defaultSelectIndex = 2;
    messageVC.isPresent = YES;
    LLNavigationViewController *nav = [[LLNavigationViewController alloc] initWithRootViewController:messageVC];
    nav.modalPresentationStyle = UIModalPresentationFullScreen;
    [self->VC presentViewController:nav animated:NO completion:nil];
}

///计算器
- (void)jisuanqi_action
{
    TTCalculatorViewController *calculatorVC = [[TTCalculatorViewController alloc] init];
    [self->VC.navigationController pushViewController:calculatorVC animated:YES];
}

/// 工厂地址
- (void)factoryAddress_action
{
    TTFactoryAddressViewController *addressVC = [[TTFactoryAddressViewController alloc] init];
    [self->VC.navigationController pushViewController:addressVC animated:YES];
}

@end
